<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<style type="text/css">
        #style-c
			{
				font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
				font-size: 12px;
				margin: 45px;
				width: 480px;
				text-align: center;
				border-collapse: collapse;
				border-top: 7px solid #9baff1;
				border-bottom: 7px solid #9baff1;
			}
			#style-c th
			{
				font-size: 13px;
				font-weight: normal;
				padding: 8px;
				background: #e8edff;
				border-right: 1px solid #9baff1;
				border-left: 1px solid #9baff1;
				color: #039;
			}
			#style-c td
			{
				padding: 8px;
				background: #e8edff; 
				border-right: 1px solid #aabcfe;
				border-left: 1px solid #aabcfe;
				color: #669;
			}

		</style>

<body>
		<%
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://localhost:3306/st?useUnicode=true&characterEncoding=utf-8";
			String user = "root";
			String pass = "123456";
			Connection con = DriverManager.getConnection(url,user,pass);
			Statement  st  = con.createStatement();
			ResultSet rs = st.executeQuery("select * from student2");
		%>
		<table id="style-c">
			<tr>
				<td>学号</td>
				<td>系部</td>
				<td>性别</td>
				<td>年龄</td>
				<td>姓名</td>
			</tr>
		<%
			while(rs.next()){
		%>
			<tr>
			<td><%=rs.getString("sno") %></td>
			<td><%=rs.getString("sdep") %></td>
			<td><%=rs.getString("ssex") %></td>
			<td><%=rs.getString("sage") %></td>
			<td><%=rs.getString("sname") %></td>
			</tr>
		<%} 
		rs.close();
		st.close();
		con.close();
		
	} catch (ClassNotFoundException e) {
		
		e.printStackTrace();
	} catch (SQLException e) {
		
		e.printStackTrace();
	}
		
		%>	
		</table>
</body>
</html>